package com.matrix.java.chap_06;

/*
    摄氏度和华氏度之间的转换
    double celsiusToFahrenheit
    double fahrenheitToCelsius
 */
public class Ex6_08 {
    public static void main(String[] args) {
        System.out.println("摄氏度\t华氏度\t\t华氏度\t摄氏度");
        double j = 120;
        for (double i = 40; i >= 30; i--) {
            double fahrenheit = celsiusToFahrenheit(i);
            System.out.printf("%.1f\t%.1f\t\t", i, fahrenheit);
            double celsius = fahrenheitToCelsius(j);
            System.out.printf("%.1f\t%.2f\t\t\n", j, celsius);
            j -= 10;
        }
    }

    private static double fahrenheitToCelsius(double fahrenheit) {
        return (5.0 / 9) * fahrenheit - 32;
    }

    private static double celsiusToFahrenheit(double celsius) {
        return (9.0 / 5) * celsius + 32;
    }
}
